package com.klod.news.widget

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp

@Composable
fun TextWithIcon(
    modifier: Modifier = Modifier,
    text: String,
    textStyle: TextStyle = MaterialTheme.typography.bodySmall,
    icon: ImageVector,
    iconTint : Color = MaterialTheme.colorScheme.onPrimaryContainer,
    iconSize: Int = 24,
    spacer: Int = 4,
    iconDescription: String? = null // For accessibility
) {
    Row(
        modifier = modifier,
        verticalAlignment = Alignment.CenterVertically // Aligns icon and text vertically
    ) {
        Icon(
            imageVector = icon,
            tint = iconTint,
            contentDescription = iconDescription,
            modifier = Modifier.size(iconSize.dp) // Adjust size as needed
        )
        Spacer(modifier = Modifier.width(spacer.dp)) // Adds space between icon and text
        Text(text = text , style = textStyle)
    }
}